﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

public partial class User_RequestsList : System.Web.UI.Page
{
    BankDataDataContext db = new BankDataDataContext();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Roles.IsUserInRole("User"))
        {
            Response.Redirect("~/Account/Login.aspx");
        }
    }

    protected void RequestListGridView_DataBinding(object sender, EventArgs e)
    {
        MembershipUser user = Membership.GetUser();
        var profiles = from profile in db.UserProfiles where profile.userId == (Guid)user.ProviderUserKey select profile;
        SqlDataSource1.SelectParameters["UserProfileId"].DefaultValue = profiles.First().ProfileId.ToString();
    }
    protected void RequestListGridView_SelectedIndexChanged(object sender, EventArgs e)
    {
        string creditRequestId = RequestListGridView.DataKeys[RequestListGridView.SelectedIndex]["CreditRequestId"].ToString();
        Session.Add("requestId", creditRequestId);
        Response.Redirect("~/User/RequestInformation.aspx");
    }
}